package org.hackystat.devcathlon.ui.page.matches;

import static org.junit.Assert.assertNotNull;
import org.apache.wicket.util.tester.FormTester;
import org.apache.wicket.util.tester.WicketTester;
import org.hackystat.devcathlon.configuration.ConfigurationException;
import org.hackystat.devcathlon.engine.test.DevcathlonTestHelper;
import org.hackystat.devcathlon.ui.DevcathlonApplication;
import org.hackystat.devcathlon.ui.page.login.LoginPage;
import org.junit.Test;

/**
 * Tests MatchesPage.
 *
 * @author John Zhou
 */
public class TestMatchesPage extends DevcathlonTestHelper {
  /**
   * Test Matches Page.
   * 
   * @throws ConfigurationException Unexpected error.
   */
  @Test
  public void testPage() throws ConfigurationException {
    WicketTester tester = new WicketTester(new DevcathlonApplication());
    tester.startPage(MatchesPage.class);
    tester.assertRenderedPage(LoginPage.class);

    FormTester formTester = tester.newFormTester("loginForm");
    formTester.setValue("user", "admin@hackystat.org");
    formTester.setValue("password", "admin@hackystat.org");
    formTester.submit();

    tester.assertRenderedPage(MatchesPage.class);
    assertNotNull("wicket ID found.", tester.getTagByWicketId("MatchesPanel"));
  }
}
